<!--begin.rcode results='hide', echo=FALSE, message=FALSE
library(caret)
data(BloodBrain)
theme1 <- caretTheme()
theme1$superpose.symbol$col = c(rgb(1, 0, 0, .4), rgb(0, 0, 1, .4), 
  rgb(0.3984375, 0.7578125,0.6445312, .6))
theme1$superpose.symbol$pch = c(15, 16, 17)
theme1$superpose.symbol$cex = 1
theme1$superpose.line$col = c(rgb(1, 0, 0, .9), rgb(0, 0, 1, .9), rgb(0.3984375, 0.7578125,0.6445312, .6))
theme1$superpose.line$lwd <- 2
theme1$superpose.line$lty = 1:3
theme1$plot.symbol$col = c(rgb(.2, .2, .2, .4))
theme1$plot.symbol$pch = 16
theme1$plot.symbol$cex = 1
theme1$plot.line$col = c(rgb(1, 0, 0, .7))
theme1$plot.line$lwd <- 2
theme1$plot.line$lty = 1

    hook_inline = knit_hooks$get('inline')
    knit_hooks$set(inline = function(x) {
      if (is.character(x)) highr::hi_html(x) else hook_inline(x)
      })
    opts_chunk$set(comment=NA, digits = 3)

library(ellipse)

session <- paste(format(Sys.time(), "%a %b %d %Y"),
                 "using caret version",
                 packageDescription("caret")$Version,
                 "and",
                 R.Version()$version.string)
    end.rcode-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <!--
  Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Emerald 
Description: A two-column, fixed-width design with dark color scheme.
Version    : 1.0
Released   : 20120902

-->
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>Visualizations</title>
  <link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'>
  <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
  </head>
  <body>
  <div id="wrapper">
  <div id="header-wrapper" class="container">
  <div id="header" class="container">
  <div id="logo">
  <h1><a href="#">Visualizations</a></h1>
</div>
  <!--
  <div id="menu">
  <ul>
  <li class="current_page_item"><a href="#">Homepage</a></li>
<li><a href="#">Blog</a></li>
<li><a href="#">Photos</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
  </div>
  -->
  </div>
  <div><img src="images/img03.png" width="1000" height="40" alt="" /></div>
  </div>
  <!-- end #header -->
<div id="page">
  <div id="content">
  <p>
  The <span class="mx funCall">featurePlot</span> function is a wrapper for different
<a href="http://cran.r-project.org/web/packages/lattice/index.html"><strong>lattice</strong></a> plots to visualize the data. For example, the following figures show the default plot for continuous outcomes generated using the <span class="mx funCall">featurePlot</span> function. 
</p>
  <p>
  For classification data sets, the <code>iris</code> data are used for illustration.
</p>
<!--begin.rcode mdrr
str(iris)
    end.rcode--> 

<h1>Scatterplot Matrix</h1>

<!--begin.rcode VisScatMat,fig.width=6.5,fig.height=6.5,tidy=FALSE
library(AppliedPredictiveModeling)
transparentTheme(trans = .4)

library(caret)
featurePlot(x = iris[, 1:4], 
            y = iris$Species, 
            plot = "pairs",
            ## Add a key at the top
            auto.key = list(columns = 3))
    end.rcode--> 


<h1>Scatterplot Matrix with Ellipses</h1>

<!--begin.rcode VisScatMatEl,fig.width=6.5,fig.height=6.5,tidy=FALSE
featurePlot(x = iris[, 1:4], 
            y = iris$Species, 
            plot = "ellipse",
            ## Add a key at the top
            auto.key = list(columns = 3))
    end.rcode-->
    
<h1>Overlayed Density Plots</h1>

<!--begin.rcode VisDens,fig.width=9,fig.height=4,tidy=FALSE,tidy=FALSE
transparentTheme(trans = .9)
featurePlot(x = iris[, 1:4], 
                  y = iris$Species,
                  plot = "density", 
                  ## Pass in options to xyplot() to 
                  ## make it prettier
                  scales = list(x = list(relation="free"), 
                                y = list(relation="free")), 
                  adjust = 1.5, 
                  pch = "|", 
                  layout = c(4, 1), 
                  auto.key = list(columns = 3))
    end.rcode-->



<h1>Box Plots</h1>

<!--begin.rcode ViBox,fig.width=9,fig.height=4,tidy=FALSE
featurePlot(x = iris[, 1:4], 
                  y = iris$Species, 
                  plot = "box", 
                  ## Pass in options to bwplot() 
                  scales = list(y = list(relation="free"),
                                x = list(rot = 90)),  
                  layout = c(4,1 ), 
                  auto.key = list(columns = 2))
    end.rcode-->

<h1>Scatter Plots</h1>


  <p>For regression, the Boston Housing data is used:</p>
<!--begin.rcode bbb,
library(mlbench)
data(BostonHousing)
regVar <- c("age", "lstat", "tax")
str(BostonHousing[, regVar])
    end.rcode--> 

<p> When the predictors are continuous, <span class="mx funCall">featurePlot</span> can
be used to create scatter plots of each of the predictors with the
outcome. For example: </p>

<!--begin.rcode VisScatter,fig.width=9,fig.height=4,tidy=FALSE
theme1 <- trellis.par.get()
theme1$plot.symbol$col = rgb(.2, .2, .2, .4)
theme1$plot.symbol$pch = 16
theme1$plot.line$col = rgb(1, 0, 0, .7)
theme1$plot.line$lwd <- 2
trellis.par.set(theme1)
featurePlot(x = BostonHousing[, regVar], 
            y = BostonHousing$medv, 
            plot = "scatter", 
            layout = c(3, 1))
    end.rcode-->


  
<p>Note that the x-axis scales are different. The function
automatically uses 
<span class="mx funCall">scales</span><tt> = <!--rinline 'list(y = list(relation = "free"))' --></tt> 
so you don't have to add it. We can also
pass in options to the <a href="http://cran.r-project.org/web/packages/lattice/index.html"><strong>lattice</strong></a> function
<span class="mx funCall">xyplot</span>. For example, we can add a scatter plot smoother
by passing in new options:</p>

<!--begin.rcode VisScatterSmooth,fig.width=9,fig.height=4,tidy=FALSE
featurePlot(x = BostonHousing[, regVar], 
            y = BostonHousing$medv, 
            plot = "scatter",
            type = c("p", "smooth"),
            span = .5,
            layout = c(3, 1))
    end.rcode-->

            
<p>The options <span class="mx arg">degree</span> and <span class="mx arg">span</span> control the
smoothness of the smoother.</p>





<div style="clear: both;">&nbsp;</div>
  </div>
  <!-- end #content -->
<div id="sidebar">
<ul>
  <li>
    <h2>General Topics</h2>
    <ul>
      <li><a href="index.html">Front Page</a></li>
      <li><a href="visualizations.html">Visualizations</a></li>
      <li><a href="preprocess.html">Pre-Processing</a><li>
      <li><a href="splitting.html">Data Splitting</a></li>
      <li><a href="varimp.html">Variable Importance</a></li>
      <li><a href="other.html">Model Performance</a></li>
      <li><a href="parallel.html">Parallel Processing</a></li>
    </ul>
    <h2>Model Training and Tuning</h2>
    <ul>
      <li><a href="training.html">Basic Syntax</a></li>
      <li><a href="modelList.html">Sortable Model List</a></li>
      <li><a href="bytag.html">Models By Tag</a></li>
      <li><a href="similarity.html">Models By Similarity</a></li>
      <li><a href="custom_models.html">Using Custom Models</a></li>
      <li><a href="sampling.html">Sampling for Class Imbalances</a></li> 
      <li><a href="random.html">Random Search</a></li> 
      <li><a href="adaptive.html">Adaptive Resampling</a></li> 
    </ul>
    <h2>Feature Selection</h2>
    <ul>
      <li><a href="featureselection.html">Overview</a>
      <li><a href="rfe.html">RFE</a></li>
      <li><a href="filters.html">Filters</a></li>
      <li><a href="GA.html">GA</a></li>
      <li><a href="SA.html">SA</a></li>
    </ul>  
  </li>
</ul>
</div>
<!-- end #sidebar -->
<div style="clear: both;">&nbsp;</div>
  </div>
  <div class="container"><img src="images/img03.png" width="1000" height="40" alt="" /></div>
  <!-- end #page -->
</div>
  <div id="footer-content"></div>
  <div id="footer">
<!--begin.rcode echo = FALSE
knit_hooks$set(inline = hook_inline)    
    end.rcode-->   
  <p>Created on <!--rinline I(session) -->.</p>
  </div>
  <!-- end #footer -->
</body>
  </html>
